import java.util.ArrayList;

public class StudentOperatoreImpl2 implements StudentOperator{

    @Override
    public void printAllInfo(ArrayList<Student> students) {
        System.out.println("===============全部学生信息如下===============");
        int boys = 0;
        int girls = 0;
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            System.out.println("姓名：" + s.getName() + "性别：" + s.getGender() + "分数：" + s.getScore());
            if(s.getGender().equals("男")) {
                boys++;
            }
            else if (s.getGender().equals("女")){
                girls++;
            }
        }
        System.out.println("男：" + boys);
        System.out.println("女：" + girls);
        System.out.println("=============================================");
    }

    @Override
    public void printAverageScore(ArrayList<Student> students) {
        int allScore = 0;
        int maxScore = students.get(0).getScore();
        int minScore = students.get(0).getScore();
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            allScore  += s.getScore();
            if(s.getScore() > maxScore) maxScore = s.getScore();
            if(s.getScore() < minScore) minScore = s.getScore();
        }
        System.out.println("最高分：" + maxScore);
        System.out.println("最低分：" + minScore);
        System.out.println("平均分：" + (allScore - minScore -maxScore) / (students.size() - 2));
    }
}
